package com.wasion.gydpe.ice;

import Ice.Application;
import Ice.Communicator;

public class InitServer extends Application {

	private CMultiPeer peer = null;

	private static InitServer instance = null;

	public synchronized static InitServer getInstance() {
		if (instance == null)
			instance = new InitServer();
		return instance;

	}

	public int run(String[] arg0) {
		Communicator commFactory = communicator();
		IceWrapper comm = new IceWrapper(commFactory, "Communication", "");
		peer = new CMultiPeer(comm);
		ReceiveMessage receiveMessage = new ReceiveMessage();
		peer.init("Communication", receiveMessage, "Remote.Proxy",
				"Remote.Proxy");
		comm.getCommunicator().waitForShutdown();
		return 0;
	}

	public InitServer() {

	}

	public static void main(String[] args) {
		InitServer app = InitServer.getInstance();

		app.main("InitServer", args, InitServer.class.getClassLoader()
				.getResource("").getPath()
				+ "IceComm.config");
	}

	public void Ice(String str1, String str2) {
		InitServer app = InitServer.getInstance();

		app.Ice("InitServer", InitServer.class.getClassLoader().getResource("")
				.getPath()
				+ "IceComm.config");
	}

	public CMultiPeer getPeer() {
		return peer;
	}

	public void setPeer(CMultiPeer peer) {
		this.peer = peer;
	}
}
